package com.cykj.pos.applet.controller;

import com.cykj.common.core.controller.BaseController;
import com.cykj.common.core.domain.AjaxResult;
import com.cykj.common.core.page.AppTableData;
import com.cykj.pos.applet.domain.ao.AppletAO;
import com.cykj.pos.applet.domain.ao.SignAO;
import com.cykj.pos.applet.domain.vo.TransactionsVO;
import com.cykj.pos.applet.service.AppletService;
import com.cykj.pos.service.IBizVerifyCodeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author wangjiaqi
 * @date 2022/1/24
 */
@Api(tags = "小程序")
@RestController
@RequestMapping("/applet")
public class AppletController extends BaseController {

    @Resource
    private AppletService appletService;

    @Resource
    private IBizVerifyCodeService iBizVerifyCodeService;

    @ApiOperation("登录")
    @PostMapping("/sign")
    public AjaxResult sign(@RequestBody SignAO signAO) {
        return appletService.sign(signAO);
    }

    @ApiOperation("列表")
    @PostMapping("/list")
    public AppTableData<TransactionsVO> getList(@RequestBody AppletAO appletAO) {
        appPage(appletAO.getPageNum(), appletAO.getPageSize());
        return getAppDataTableList(appletService.getList(appletAO));
    }

    @ApiOperation(value = "验证码")
    @GetMapping("/sender/{mobile}")
    public AjaxResult verifyCodeSenderWeChat(@PathVariable String mobile) {
        //公众号提现短信验证码
        return iBizVerifyCodeService.sendVerifyCodeWeChat(mobile);
    }

}
